<?php
/* 	These code was generated using phpCIGen v 0.1.b (21/04/2009)
	#zaqi 		zaqi.smart@gmail.com,http://zenzaqi.blogspot.com, 
	
	+ Module  		: tbl_s_info Controller
	+ Description	: For record controller process back-end
	+ Filename 		: C_tbl_s_info.php
 	+ creator 		: 
 	+ Created on 22/Jan/2012 19:08:53
	
*/

//class of tbl_s_info
class C_tbl_s_info extends CI_Controller {

	//constructor
	function C_tbl_s_info(){
		parent::__construct();
		$this->load->model('m_tbl_s_info', '', TRUE);

		
		// if(!$_SESSION[SESSION_USERID])
			// redirect('c=c_login', 'location', 301);
			checkLogin();
	}
	
	//set index
	function index(){
		$this->load->view('main/v_tbl_s_info');
	}
	
	//event handler action
	function get_action(){
		$task = $_POST['task'];
		switch($task){
			case "LIST":
				$this->tbl_s_info_list();
				break;
			case "UPDATE":
				$this->tbl_s_info_update();
				break;
			default:
				echo "{failure:true}";
				break;
		}
	}
	
	//function fot list record
	function tbl_s_info_list(){
		
		$query = isset($_POST['query']) ? @$_POST['query'] : "";
		$start = (integer) (isset($_POST['start']) ? @$_POST['start'] : @$_GET['start']);
		$end = (integer) (isset($_POST['limit']) ? @$_POST['limit'] : @$_GET['limit']);
		$result=$this->m_tbl_s_info->tbl_s_info_list($query,$start,$end);
		echo $result;
	}
	
	//function for update record
	function tbl_s_info_update(){
		//POST variable here
		$info_id=trim(@$_POST["info_id"]);
		$info_nama=trim(@$_POST["info_nama"]);
		$info_nama=str_replace("/(<\/?)(p)([^>]*>)", "",$info_nama);
		$info_nama=str_replace("'", "''",$info_nama);
		$info_dvo=trim(@$_POST["info_dvo_nama"]);
		//echo "<script>alert('".$info_dvo."');</script>";
		$info_alamat=trim(@$_POST["info_alamat"]);
		$info_alamat=str_replace("/(<\/?)(p)([^>]*>)", "",$info_alamat);
		$info_alamat=str_replace("'", "''",$info_alamat);
		$info_notelp=trim(@$_POST["info_notelp"]);
		$info_notelp=str_replace("/(<\/?)(p)([^>]*>)", "",$info_notelp);
		$info_notelp=str_replace("'", "''",$info_notelp);
		$info_nofax=trim(@$_POST["info_nofax"]);
		$info_nofax=str_replace("/(<\/?)(p)([^>]*>)", "",$info_nofax);
		$info_nofax=str_replace("'", "''",$info_nofax);
		$info_email=trim(@$_POST["info_email"]);
		$info_email=str_replace("/(<\/?)(p)([^>]*>)", "",$info_email);
		$info_email=str_replace("'", "''",$info_email);
		$info_website=trim(@$_POST["info_website"]);
		$info_website=str_replace("/(<\/?)(p)([^>]*>)", "",$info_website);
		$info_website=str_replace("'", "''",$info_website);
		$info_slogan=trim(@$_POST["info_slogan"]);
		$info_slogan=str_replace("/(<\/?)(p)([^>]*>)", "",$info_slogan);
		$info_slogan=str_replace("'", "''",$info_slogan);
		//$info_logo=trim(@$_POST["info_logo"]);
		//$info_logo=str_replace("/(<\/?)(p)([^>]*>)", "",$info_logo);
		//$info_logo=str_replace("'", "''",$info_logo);
		$info_logo=@$_FILES['info_logo']['name'];
		$info_logo_tmp=@$_FILES['info_logo']['tmp_name'];
		$info_icon=trim(@$_POST["info_icon"]);
		$info_icon=str_replace("/(<\/?)(p)([^>]*>)", "",$info_icon);
		$info_icon=str_replace("'", "''",$info_icon);
		//$info_background=trim(@$_POST["info_background"]);
		//$info_background=str_replace("/(<\/?)(p)([^>]*>)", "",$info_background);
		//$info_background=str_replace("'", "''",$info_background);
		$info_background=@$_FILES['info_background']['name'];
		$info_background_tmp=@$_FILES['info_background']['tmp_name'];
		$info_theme=trim(@$_POST["info_theme"]);
		$info_theme=str_replace("/(<\/?)(p)([^>]*>)", "",$info_theme);
		$info_theme=str_replace("'", "''",$info_theme);
		$result = $this->m_tbl_s_info->tbl_s_info_update($info_id,$info_nama,$info_dvo,
										$info_alamat,$info_notelp,$info_nofax,$info_email,
										$info_website,$info_slogan,$info_logo,$info_logo_tmp,$info_icon,
										$info_background,$info_background_tmp,$info_theme);
		//echo $result;
		//echo "{success:true}";
	}
	
	
	
	// Encodes a SQL array into a JSON formated string
	function JEncode($arr){
		if (version_compare(PHP_VERSION,"5.2","<"))
		{    
			require_once("./JSON.php"); //if php<5.2 need JSON class
			$json = new Services_JSON();//instantiate new json object
			$data=$json->encode($arr);  //encode the data in json format
		} else {
			$data = json_encode($arr);  //encode the data in json format
		}
		return $data;
	}
	
	// Decode a SQL array into a JSON formated string
	function JDecode($arr){
		if (version_compare(PHP_VERSION,"5.2","<"))
		{    
			require_once("./JSON.php"); //if php<5.2 need JSON class
			$json = new Services_JSON();//instantiate new json object
			$data=$json->decode($arr);  //decode the data in json format
		} else {
			$data = json_decode($arr);  //decode the data in json format
		}
		return $data;
	}
	
	
}
?>